package com.hq.service.impl;

import org.apache.ibatis.session.SqlSession;

import com.hq.dao.UserInfoMapper;
import com.hq.pojo.UserInfo;
import com.hq.service.UserInfoService;
import com.hq.utils.MyBatisUtil;

public class UserInfoImpl implements UserInfoService {
	
	

	@Override
	public UserInfo getUserInfoById(int accountId) {
		SqlSession session = null;
		UserInfo userInfo = null;
		try {
			session = MyBatisUtil.getSqlSession(true);
			UserInfoMapper userInfoMapper = session.getMapper(UserInfoMapper.class);
			userInfo = userInfoMapper.getUserInfoById(accountId);
			return userInfo;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyBatisUtil.closeSqlSession(session);
		}
		return userInfo;
	}

	@Override
	public int updateUserInfoById(UserInfo userInfo) {
		// TODO 自动生成的方法存根
		SqlSession session = null;
		try {
			session = MyBatisUtil.getSqlSession(true);
			UserInfoMapper userInfoMapper = session.getMapper(UserInfoMapper.class);
			int i = userInfoMapper.updateUserInfoById(userInfo);
			return i;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyBatisUtil.closeSqlSession(session);
		}
		return 0;
	}

}
